package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhServiceOrderApplymoney;
import com.ruoyi.zsyh.service.IZsyhServiceOrderApplymoneyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费用单管理Controller
 * 
 * @author yuexl
 * @date 2022-09-06
 */
@Controller
@RequestMapping("/zsyh/serviceOrderApplymoney")
public class ZsyhServiceOrderApplymoneyController extends BaseController
{
    private String prefix = "zsyh/serviceOrderApplymoney";

    @Autowired
    private IZsyhServiceOrderApplymoneyService zsyhServiceOrderApplymoneyService;

    @RequiresPermissions("zsyh:serviceOrderApplymoney:view")
    @GetMapping()
    public String serviceOrderApplymoney()
    {
        return prefix + "/serviceOrderApplymoney";
    }

    /**
     * 查询费用单管理列表
     */
    @RequiresPermissions("zsyh:serviceOrderApplymoney:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhServiceOrderApplymoney zsyhServiceOrderApplymoney)
    {
        startPage();
        List<ZsyhServiceOrderApplymoney> list = zsyhServiceOrderApplymoneyService.selectZsyhServiceOrderApplymoneyList(zsyhServiceOrderApplymoney);
        return getDataTable(list);
    }

    /**
     * 查询费用单管理列表
     */
    @RequiresPermissions("zsyh:serviceOrderApplymoney:list")
    @PostMapping("/listById")
    @ResponseBody
    public TableDataInfo listById(String id)
    {
        ZsyhServiceOrderApplymoney zsyhServiceOrderApplymoney = new ZsyhServiceOrderApplymoney();
        zsyhServiceOrderApplymoney.setOrderId(id);
        List<ZsyhServiceOrderApplymoney> list = zsyhServiceOrderApplymoneyService.selectZsyhServiceOrderApplymoneyList(zsyhServiceOrderApplymoney);
        return getDataTable(list);
    }

    /**
     * 导出费用单管理列表
     */
    @RequiresPermissions("zsyh:serviceOrderApplymoney:export")
    @Log(title = "费用单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhServiceOrderApplymoney zsyhServiceOrderApplymoney)
    {
        List<ZsyhServiceOrderApplymoney> list = zsyhServiceOrderApplymoneyService.selectZsyhServiceOrderApplymoneyList(zsyhServiceOrderApplymoney);
        ExcelUtil<ZsyhServiceOrderApplymoney> util = new ExcelUtil<ZsyhServiceOrderApplymoney>(ZsyhServiceOrderApplymoney.class);
        return util.exportExcel(list, "费用单管理数据");
    }

    /**
     * 新增费用单管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存费用单管理
     */
    @RequiresPermissions("zsyh:serviceOrderApplymoney:add")
    @Log(title = "费用单管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhServiceOrderApplymoney zsyhServiceOrderApplymoney)
    {
        return toAjax(zsyhServiceOrderApplymoneyService.insertZsyhServiceOrderApplymoney(zsyhServiceOrderApplymoney));
    }

    /**
     * 修改费用单管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhServiceOrderApplymoney zsyhServiceOrderApplymoney = zsyhServiceOrderApplymoneyService.selectZsyhServiceOrderApplymoneyById(id);
        mmap.put("zsyhServiceOrderApplymoney", zsyhServiceOrderApplymoney);
        return prefix + "/edit";
    }

    /**
     * 修改保存费用单管理
     */
    @RequiresPermissions("zsyh:serviceOrderApplymoney:edit")
    @Log(title = "费用单管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhServiceOrderApplymoney zsyhServiceOrderApplymoney)
    {
        return toAjax(zsyhServiceOrderApplymoneyService.updateZsyhServiceOrderApplymoney(zsyhServiceOrderApplymoney));
    }

    /**
     * 删除费用单管理
     */
    @RequiresPermissions("zsyh:serviceOrderApplymoney:remove")
    @Log(title = "费用单管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhServiceOrderApplymoneyService.deleteZsyhServiceOrderApplymoneyByIds(ids));
    }
}
